<script type="text/javascript" src="<?php echo base_url(); ?>static/select2/select2.min.js" ></script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/js/selectSearchGlobal.js"></script>

<script>
    function appGaSave() {
            $.post("<?= site_url() ?>search_global/app_gaSave", {
                pCTab: $('#pCTab').val(),
                pCType: $('#pCType').val(),
                pCtrlID: $('#pCtrlID').val(),
                pApproval: $('#pApproval').val(),
                pNikRequestBy: $('#pNikRequestBy').val(),
                pComment: $('#pComment').val(),
                //pAccesNo: $('#pAccesNo').val()
            },
            function(data) {
                window.location = '<?php echo base_url(); ?>search_global';
            }
            );
        }
    function cancel(){
        window.location = '<?php echo base_url(); ?>search_global';
    }
</script>


<?php
$this->load->model("sGlobal_model");
if(!empty($cRequestNo)){
    foreach($getDetail as $a){
    
    	
        
        $aId   			= $a["SIK_ID"];
    	$aNik   		= $a["SIK_NIK"];
    	$aSdate   		= $a["SIK_SDATE"];
    	$aEdate   		= $a["SIK_EDATE"];
    	$aShours   		= $a["SHOURS"];
    	$aEhours   		= $a["EHOURS"];
    	$aShoure   		= $a["SHOURE"];
    	$aEhoure   		= $a["EHOURE"];
    	$aVendorId   	= $a["VENDOR_ID"];
    	$aVendorName   	= $a["VENDOR_NAME"];
    	$aVendorJabatan = $a["VENDOR_JABATAN"];
    	$aVendorPic   	= $a["VENDOR_PIC"];		
    	$aUntukNik   		= $a["SIK_UNTUK_NIK"];
        
        $aSikAtasanNik  = $a["SIK_ATASAN_NIK"];
    	$aSikAtasanName = $this->sGlobal_model->getName($aSikAtasanNik);
    	$cName			= $this->sGlobal_model->getName($aUntukNik);
    	$cJob			= $this->sGlobal_model->getJobPosition($aUntukNik);
    	$cOrg			= $this->sGlobal_model->getOrg($aUntukNik);
    
    	$aName = $this->sGlobal_model->getName($aNik);
    	$aJob  = $this->sGlobal_model->getJobPosition($aNik);
    	$aOrg  = $this->sGlobal_model->getOrg($aNik);
    }
}
?>
<div id="top" >
	<form id="formarea" role="form" method="post" action="#" class="form-horizontal">
    <input type="hidden" value="<?php echo $cSikjId; ?>" id="cSikjId" />
    <input type="hidden" value="<?php echo $cRequestNo; ?>" id="pCtrlID" />
    <input type="hidden" value="<?php echo $cTab; ?>" id="pCTab" />
    <input type="hidden" value="<?php echo $cType; ?>" id="pCType" />
    <input type="hidden" value="<?php echo $aNik;?>" id="pNikRequestBy" name="pNikRequestBy"/>
    
	<div class="col-md-offset-0">
		<div class="col-md-11">
            <div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Request By</b></h4></div>
				<div class="panel-body">
                
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-3">NIK</label>
							<div class="col-md-7"><input type="text" value="<?php echo $aNik;?>" id="pNik" class="select2 form-control input-sm" readonly=""/></div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-3">Nama</label>
							<div class="col-md-7"><input type="text" value="<?php echo $aName;?>" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
					<div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7"><input type="text" value="<?php echo $aOrg;?>" class="form-control input-sm" readonly=""/></div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8"><input type="text" value="<?php echo $aJob;?>" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
				</div>
			</div>
            
			<div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Requestor</b></h4></div>
				<div class="panel-body">
                
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-3">Nama</label>
							<div class="col-md-7">
                                <input type="text" id="r_nama" class="select2 form-control input-sm" value="<?php echo $cName;?>" readonly=""/>
                            </div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-3">ID</label>
							<div class="col-md-3"><input type="text" value="<?php echo $aUntukNik;?>" id="r_id" class="form-control input-sm" readonly=""/></div>
						</div>
						<div class="form-group">
                            <input type="hidden" id="r_mgrid" value="<?php echo $aSikAtasanNik;?>"/>
							<label class="control-label col-md-3">Nama Atasan</label>
							<div class="col-md-9"><input type="text" value="<?php echo $aSikAtasanName;?>" id="r_mgr" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
					<div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7"><input type="text" value="<?php echo $cOrg;?>" id="r_dept" class="form-control input-sm" readonly=""/></div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8"><input type="text" value="<?php echo $cJob;?>" id="r_job" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title"><b class="caret"></b><b> Request</b></h4>
				</div>
				<div class="panel-body">
					<div class="col-md-6">
						<div class="form-group">
							<label class="control-label col-md-2">Vendor</label>
							<div class="col-md-9">
                                <input type="hidden" id="jumlahVendor" value="1"/>
                                <input type="hidden" id="r_venid0" value="<?php echo $aVendorId;?>" readonly="" class="form-control input-sm"/>
                                <input id="r_vennama0" type="text" class="form-control input-sm" size="55" value="<?php echo $aVendorName;?>" readonly=""/>
                            </div>              
						</div>
						<div class="form-group">
							<label class="control-label col-md-2">PIC</label>
							<div class="col-md-4"><input id="pPic" type="text" class="form-control input-sm" value="<?php echo $aVendorPic; ?>" size="30" readonly=""/></div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-2">Jabatan</label>
							<div class="col-md-4"><input id="pJabatan" type="text" class="form-control input-sm" value="<?php echo $aVendorJabatan;?>" size="30" readonly=""/></div>
						</div>
                        
					</div>
					<div class="col-md-6">
						<div class="form-group">
							<label class="control-label col-md-2">Tanggal Pekerjaan</label>
							<div class="col-md-4 form-group ">
									<div class="form-group">
										<input type="text" class="form-control input-sm" name="date_start" id="datepicker1" value="<?php echo $aSdate; ?>" readonly=""/>
									</div>
								
							</div>
							<div class="col-md-1" style="text-align:center">-</div>
							<div class="col-md-4 form-group ">
									<div class="form-group">
										<input type="text" class="form-control input-sm" name="date_start" id="datepicker2" value="<?php echo $aEdate; ?>" readonly=""/>
									</div>
								
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-2">Jam Pekerjaan</label>
							<div class="col-md-2"><input type="text" class="form-control input-sm" id="pShour" value="<?php echo $aShours;?>" readonly=""/> </div>
                            <div class="col-md-1">:</div>
                            <div class="col-md-2"><input type="text" class="form-control input-sm" id="pSminute" value="<?php echo $aEhours;?>" readonly=""/></div>
                            <div class="col-md-1">s/d</div>
						</div>
                        <div class="form-group">
                            <label class="control-label col-md-2"></label>
                            <div class="col-md-2"><input type="text" class="form-control input-sm" id="pEhour" value="<?php echo $aShoure;?>" readonly=""/></div>
                            <div class="col-md-1">:</div>
                            <div class="col-md-2"><input type="text" class="form-control input-sm" id="pEminute" value="<?php echo $aEhoure;?>" readonly=""/></div>
						</div>
					</div>
                    
                    
                    
					<div class="col-md-12 well well-sm" id="bawahForm">
						<div class="form-group">
							<div class="col-md-5"><label style="color:#003399">
                            </label></div>
						</div>
						<div class="form-group">
							<div class="col-md-12">
								<table class="table table-bordered table-condensed table-striped" style="margin-bottom:0px">
									<tbody>
										<tr>
											<!--<td class="tblhead" style="width:3%;text-align:center"></td>-->
											<th class="tblhead" style="width:3%;text-align:center">No.</th>
											<th class="tblhead" style="width:15%;text-align:center">Nama</th>
											<th class="tblhead" style="width:20%;text-align:center">Pekerjaan</th>
											<th class="tblhead" style="width:7%;text-align:center">Lantai</th>										
											<th class="tblhead" style="width:20%;text-align:center">Location</th>
											<th class="tblhead" style="width:8%;text-align:center">Access</th>										
											<th class="tblhead" style="width:10%;text-align:center">Nama Barang</th>
											<th class="tblhead" style="width:15%;text-align:center">S/N</th>										
										</tr>
								<!--	</tbody>
								</table>
								<table id="dataTable" class="table table-bordered table-condensed table-striped">
									<tbody>-->	
                                    <?php
									   $i_job=0;
									   $no_job=1;
									   if(!empty($cRequestNo)){
									       foreach ($getDetail2 as $b){
									           $bId   	   = $b["SIKJ_ID"];
                                               $bName  	   = $b["SIKJ_NAME"];
							                   $bPekerjaan = $b["SIKJ_DESC"];
											   $bLantai    = $b["SIKJ_FLOOR"];
											   $bLocation  = $b["SIKJ_LOCATION"];
											   $bAccess    = $b["SIKJ_ACCESS"];
                                               $bBarang    = $b["SIKJ_BARANG"];
									           $bSn  	   = $b["SIKJ_SN"];
                                               
									?>
										<tr>
											<!--<td style="width:3%;"><input type="checkbox" required="required" name="chk[]" /></td>-->
											<td style="width:3%;"><?php echo $i_job+1;?></td>
											<td style="width:15%;"><?php echo $bName; ?></td>
											<td style="width:20%;"><?php echo $bPekerjaan; ?></td>
											<td style="width:7%;"><?php echo $bLantai; ?></td>
											<td style="width:20%;text-align:center"><?php echo $bLocation; ?></td>
											<td style="width:8%;text-align:center"><?php echo $bAccess=='Y'?'Ya':'Tidak'; ?></td>
											<td style="width:10%;text-align:center"><?php echo $bBarang; ?></td>
											<td style="width:15%;text-align:center"><?php echo $bSn; ?></td>																												
										</tr>
                                        <input type="hidden" id="pSikjId<?php echo $i_job; ?>" value="<?php echo $bId; ?>"/>
                                    <?php
    	                                   $i_job++;
    									   $no_job++;
									   }?>
                                       <input type="hidden" id="pJumlahI" value="<?php echo $i_job; ?>"/>
                                       <?php
									}
									?>
									</tbody>
								</table>
							</div>
						</div>
					</div>
                    
                    <div class="row"> 
                        <div class="col-sm-12">
                            <div class="form-group">
                                <label class="control-label col-md-3">Comment</label>
                                <div class="col-md-7">
								<textarea id="pComment" class="form-control input-sm" style="min-width:190px;max-width:200px;min-height:100px;max-height:200px;">
                                </textarea>
							</div>
    				        </div>
                        </div>                   
                    </div>
                    
                    <div class="row"> 
                        <div class="col-sm-12">
                            <div class="form-group">
    							<label class="control-label col-md-2">Approval</label>
    							<div class="col-md-4">
                                    <select class="form-control input-form select2" id="pApproval" style="width:100%">
                                			<option value="Y">Approve</option>
                                            <option value="N" selected="">Disapprove</option>
        				            </select>
                                </div>
    						</div>
                        </div>                   
                    </div>    
					<div class="row"> 
                        <div class="col-sm-12">
                            <div class="form-group">
                                <label class="control-label col-md-3"></label>
        						<div class="col-sm-2">
                                    <button type="button" class="btn btn-primary btn-block" onclick="appGaSave();">Submit</button>
                                </div>
                                <div class="col-sm-2">
                                    <button type="button" class="btn btn-default btn-block" onclick="cancel();" >Cancel</button>
                                </div>
    				        </div>
                        </div>                   
                    </div>
				</div>
			</div>
		</div>
	</div>
	</form>
</div>